package com.dries.security.core.social.qq.config;

import com.dries.security.core.properties.SecurityCoreProperties;
import com.dries.security.core.properties.social.QQProperties;
import com.dries.security.core.social.config.SocialAutoConfigurerAdapter;
import com.dries.security.core.social.qq.connect.QQConnectionFactory;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.context.annotation.Configuration;
import org.springframework.social.connect.ConnectionFactory;

import javax.annotation.Resource;

/**
 * @Description:
 * @Author ZSY
 * @createTime 2020/9/15 19:38
 */
@Configuration
@ConditionalOnProperty(prefix = "dries.security.social.qq", name = "appId")
public class QQAutoConfig extends SocialAutoConfigurerAdapter {

    @Resource
    private SecurityCoreProperties coreProperties;

    @Override
    protected ConnectionFactory<?> createConnectionFactory() {

        QQProperties qq = coreProperties.getSocial().getQq();

        return new QQConnectionFactory(qq.getProviderId(),qq.getAppId(),qq.getAppSecret());
    }
}
